<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>使用工厂方法创建对象</title>
</head>
<body>
<script>
    /*
     *
     *
     *
     *
     *
     */
    function createPerson(name,age,gender) {
        var obj=new Object();
            obj.name=name;
            obj.age=age;
            obj.gender=gender;
            obj.sayName=function () {
            alert(this.name);
            };
            return obj;//将新的对象返回
    }
    function createDog(name,age) {
        var obj10=new Object();
            obj10.name=name;
            obj10.age=age;
            obj10.sayHello=function () {
                alert("旺旺");
            };
            return obj10;
    }
    var obj2=createPerson("哪咤",15,"男");
    var obj3=createPerson("织女",28,"女");
    console.log(obj2);
    console.log(obj3);
   var obj4=createDog("旺财",3);
   console.log(obj4);

</script>
</body>
</html>